package com.expand04;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by yangjun on 2018/3/23.
 */
public class ProductFactory {
    public static final Map<String, Product> prMap = new HashMap<>();

    public static synchronized Product createProduct(String type) {
        Product product = null;

        if(prMap.containsKey(type)) {
            product = prMap.get(type);
        } else {
            if("Product1".equals(type)) {
                product = new ConcreteProduct1();
            }else {
                product = new ConcreteProduct2();
            }
        }
        return product;
    }
}
